/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.springtree.spectrum.orm.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ricardo
 */
@Entity
@Table(name = "command_rule")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CommandRule.findAll", query = "SELECT c FROM CommandRule c"),
    @NamedQuery(name = "CommandRule.findByCommandruleId", query = "SELECT c FROM CommandRule c WHERE c.commandruleId = :commandruleId")})
public class CommandRule implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "commandrule_id")
    private Integer commandruleId;
    @JoinColumn(name = "rule_id", referencedColumnName = "rule_id")
    @ManyToOne
    private Rule ruleId;
    @JoinColumn(name = "command_id", referencedColumnName = "command_id")
    @ManyToOne
    private Command commandId;

    public CommandRule() {
    }

    public CommandRule(Integer commandruleId) {
        this.commandruleId = commandruleId;
    }

    public Integer getCommandruleId() {
        return commandruleId;
    }

    public void setCommandruleId(Integer commandruleId) {
        this.commandruleId = commandruleId;
    }

    public Rule getRuleId() {
        return ruleId;
    }

    public void setRuleId(Rule ruleId) {
        this.ruleId = ruleId;
    }

    public Command getCommandId() {
        return commandId;
    }

    public void setCommandId(Command commandId) {
        this.commandId = commandId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commandruleId != null ? commandruleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommandRule)) {
            return false;
        }
        CommandRule other = (CommandRule) object;
        if ((this.commandruleId == null && other.commandruleId != null) || (this.commandruleId != null && !this.commandruleId.equals(other.commandruleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.springtree.spectrum.orm.entities.CommandRule[ commandruleId=" + commandruleId + " ]";
    }
    
}
